package com.rmuti.programming.testswt;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

public class UITest3 {

	public static void main(String[] args) {
		final Display display = new Display();
		Shell shell = new Shell(display);
		shell.setSize(500, 500);
		GridLayout layout = new GridLayout();
		shell.setLayout(layout);
//		shell.setBackgroundMode(SWT.INHERIT_DEFAULT); 

		Composite composite = new Composite(shell, SWT.SHADOW_NONE);
		GridData bgTopMenuLayout = new GridData(385, 55);
//		composite.setLayoutData(bgTopMenuLayout);
//		composite.setBackgroundMode(SWT.INHERIT_DEFAULT);
		
		final Image image = new Image(display, "icons/image/header.gif");

		Canvas canvas = new Canvas(shell, SWT.NONE);
		canvas.setLayoutData(bgTopMenuLayout);
		canvas.addPaintListener(new PaintListener() {
			public void paintControl(PaintEvent e) {
				e.gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); 
				e.gc.drawImage(image, 0, 0);
				e.gc.drawText("การปฎิบัติการคอมพิวเตอร์", 50, 10, true);
			}
		});	
		
		Label label1 = new Label(composite, SWT.PUSH);
		label1.setText("test");
		label1.setLayoutData(bgTopMenuLayout);
//		label1.pack();
		
		shell.open();
	    while (!shell.isDisposed()) {
	      if (!display.readAndDispatch())
	        display.sleep();
	    }
	    display.dispose();		
	}
}
